Custom web forms – Part 1: Exporting Form into DXL
The one thing that in my opinion always lacked in Lotus Notes was the ability for users without designer access (and much knowledge of HTML) to build their own custom forms. One might argue that it is not that big of a deal and that it would take an experienced developer approximately one hour to create and test such a form. However, developers usually have more important work to do and this is an hour unnecessary spent.
How to get around…
I am positive that different developers would handle this differently. For sure, the easiest thing to do would be to add designer access to a person wishes to create a form. I would advise against it. Not only it creates severe security issue, but it also enables inexperienced user to poke about the database design.
I am positive every designer till now at least heard of DXL. Some of us even used it. I did it for exporting entire database to our internal wiki and to create atom rss for another database. However, most developers, in my experience, look at DXL as a bit of a Notes voodoo.
Let’s remove this tag!
In several parts, I will try to show how to export and import a simple HTML form that one can use on the web. Also at the very end, I will try to create a form that will enable a user with less than developer access to create a web form.
Onward, to the point – Exporting Form to DXL
It is quite simple. You create or already posses a form. For exporting it to DXL, you will need to know it’s name or you can enable for to be available in Create menu and add a shared action onto it, that will do the work for you. I decided for the later.
Figure above displays a simple form previewed in Notes client with shared action “Export form”in action bar. Upon clicking on this action, a file will be saved on your disk to path c:\download\my_form_name.xml. And below is the code that does all this.
Sub Click(Source As Button) Dim ws As New NotesUIWorkspace Dim s As New NotesSession Dim db As NotesDatabase Dim nc As NotesNoteCollection Dim doc As NotesDocument Dim docForm As NotesDocument Dim stream As NotesStream Dim dxlExporter As NotesDXLExporter Dim bFound As Boolean Dim n As Integer Dim strId As String Dim strFormName As String Set db = s.CurrentDatabase Set doc = ws.CurrentDocument.Document Set nc = db.CreateNoteCollection (False) nc.SelectForms = True Call nc.BuildCollection () bFound = False strId = nc.GetFirstNoteId () For n = 1 To nc.Count Set docForm = db.GetDocumentByID (strId) strFormName = docForm.GetFirstItem ("$title").values(0) If (doc.Form (0) = strFormName) Then bFound = True Exit For End If strId = nc.GetNextNoteId (strId) Next If (Not bFound) Then Exit Sub Set stream = s.CreateStream () Call stream.Open("c:\download\" & strFormName & ".xml","utf-8") Call stream.Truncate () Set dxlExporter = s.CreateDXLExporter (docForm, stream) Call dxlExporter.Process Call stream.Close () End Sub
April 6th, 2009 at 18:01
my God, i thought you were going to chip in with some decisive insght at the end there, not leave it with
April 7th, 2009 at 08:34
Part I was only about exporting a simple form to DXL. As far as I know, exporting forms to DXL is never a problem. When I migrated our Tips&Tricks database to a wiki, there wasn’t a single form that would cause problems. And those forms contained a Body Rich text item, where users copy & pasted content directly from web, word, excel etc.
April 9th, 2009 at 17:34
FANTASTIC!
May 30th, 2009 at 03:20
found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later ..
January 27th, 2010 at 14:37
How to export UTF characters in DXL
February 2nd, 2010 at 20:43
As far as I know, the solution is above. You have to state to your input file that it is utf-8 or whatever other code format you are using.